<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form-admin-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员：</label>
            <div class="formControls col-xs-8 col-sm-9">
                {$detail['username']}
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">昵称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" id="nickname" name="nickname" value="{$detail['nickname']}">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="email" class="input-text" name="email" id="email" value="{$detail['email']}">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="提交">
            </div>
        </div>
    </form>
</article>

<!--请在下方写此页面业务相关的脚本-->
<script src="/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script>
    $(function(){
        //表单验证
        $("#form-admin-add").validate({
            rules:{
                username:{
                    required:true,
                    minlength:4,
                    maxlength:16
                },
                password:{
                    required:true
                },
                password2:{
                    required:true,
                    equalTo: "#password"
                },
                email:{
                    required:true,
                    email:true
                }
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                //ajax提交表单
                $(form).ajaxSubmit({
                    type: $(form).attr('method'),
                    url: $(form).attr('action'),
                    success: function(response){
                        if (response.code == 1) {
                            layer.msg(response.msg,{icon:1,time:1000},function(){
                                //这里关闭（避免ajax还没发送出去就关闭了iframe框架）
                                window.parent.location.reload();
                            });
                        }else{
                            layer.msg(response.msg, {icon:0,time:3000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg('发送失败!',{icon:0,time:3000});
                    }
                });
            }
        });
    });
</script>
<!--/请在上方写此页面业务相关的脚本-->